<template>

	<view>
		<view class="content">
			<u-form>

				<u-form-item label="姓名" borderBottom labelWidth="50">
					<u--input v-model="name" border="none" style="color: #007AFF;"></u--input>
				</u-form-item>

				<u-form-item label="性别" prop="userInfo.sex" borderBottom @click="showSex = true;"
					ref="item1">
					<u--input v-model="model1.userInfo.sex" :placeholder="sex" border="none"></u--input>
					<u-icon slot="right" name="arrow-right"></u-icon>
				</u-form-item>
				<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" @close="showSex = false"
					@select="sexSelect">
				</u-action-sheet>

				<u-form-item label="生日" borderBottom labelWidth="50">
					<u--input v-model="birthday" border="none" style="color: #007AFF;"></u--input>
				</u-form-item>

				<u-form-item label="手机号" borderBottom labelWidth="50">
					<u--input v-model="phone" border="none" style="color: #007AFF;"></u--input>
				</u-form-item>

				<u-form-item label="地址" borderBottom labelWidth="50">
					<u--input v-model="address" border="none" style="color: #007AFF;"></u--input>
				</u-form-item>
			</u-form>

			</u--form>
		</view>

		<u-button id="submit" type="primary" text="提交" customStyle="margin-top: 30px;" @click="submit"
			style="clear: all;"></u-button>

	</view>


</template>

<script>
	export default {
		data() {
			return {
				name: "韦唐亮",
				sex: "男",
				birthday: "2021-11-11",
				phone: "12345678",
				address: "广东省梅州市",

				showSex: false,
				model1: {
					userInfo: {
						sex: '',
					},
				},
				actions: [{
						name: '男',
					},
					{
						name: '女',
					},
				],
				rules: {
					'userInfo.sex': {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
				},
			}
		},

		onLoad() {
			//在这里发送请求，获取用户信息
			// wx.cloud.callContainer({
			// 	config: {
			// 		env: "prod-9gaetadn0414eb27"
			// 	},
			// 	path: "/authority/user/wechat/bind",
			// 	header: {
			// 		"X-WX-SERVICE": "springboot-authority",
			// 		"content-type": "application/json",
			// 		xip: getApp().globalData.xip
			// 	},
			// 	method: "POST",
			// 	data: body,
			// 	success(res) {
			// 		console.log(res, '登录结果')
			// 	},
			// 	fail(error) {
			// 		console.log('失败', error)
			// 	}
			// })
		},

		methods: {
			click() {
				console.log('Cell is clicked.');
			},

			sexSelect(e) {
				this.model1.userInfo.sex = e.name
				this.$refs.form1.validateField('userInfo.sex')
			},
		}
	}
</script>

<style lang="scss">
	.content {
		display: flex;
		margin-left: 5px;
		/* 默认是行,弹性 */
		flex-direction: column;
	}

	.content #submit {
		margin-left: 0px;
	}
</style>
